package dictimpl

import (
	"context"

	"gorm.io/gorm"

	"go-caipu/pkg/services/admin/dict"
)

type Service struct {
	store store
}

func ProvideService(db *gorm.DB) (*Service, error) {
	store := ProvideStore(db)
	s := &Service{
		store: store,
	}
	return s, nil
}

func (s *Service) GetSysDictTypePage(ctx context.Context, cmd dict.GetSysDictTypePageCommand) (result []dict.SysDictType, num int64, err error) {
	result, num, err = s.store.GetSysDictTypePage(ctx, cmd)
	if err != nil {
		return
	}
	return
}

func (s *Service) Get(ctx context.Context, cmd dict.GetSysDictTypeCommand) (dict.SysDictType, error) {
	return s.store.Get(ctx, cmd)
}

func (s *Service) Insert(ctx context.Context, cmd dict.SysDictType) error {
	return s.store.Insert(ctx, cmd)
}

func (s *Service) Update(ctx context.Context, cmd dict.SysDictType) error {

	return s.store.Update(ctx, cmd)
}

func (s *Service) Remove(ctx context.Context, cmd dict.RemoveSysDictTypeCommand) error {
	return s.store.Remove(ctx, cmd)
}

// GetSysDictDataPage 获取值列表
func (s *Service) GetSysDictDataPage(ctx context.Context, cmd dict.GetSysDictDataPageCommand) (data []dict.SysDictData, num int64, err error) {
	data, num, err = s.store.GetSysDictDataPage(ctx, cmd)
	return
}

// GetDictDataOptions 获取值列表
func (s *Service) GetDictDataOptions(ctx context.Context, dictType string) (data []dict.Options, err error) {
	data, err = s.store.GetDictDataOptions(ctx, dictType)
	return
}

func (s *Service) GetDictData(ctx context.Context, cmd dict.GetSysDictDataCommand) (dict.SysDictData, error) {
	return s.store.GetDictData(ctx, cmd)
}
func (s *Service) InsertDictData(ctx context.Context, cmd dict.SysDictData) error {
	return s.store.InsertDictData(ctx, cmd)
}
func (s *Service) UpdateDictData(ctx context.Context, cmd dict.SysDictData) error {
	return s.store.UpdateDictData(ctx, cmd)
}
func (s *Service) RemoveDictData(ctx context.Context, cmd dict.RemoveSysDictDataCommand) error {
	return s.store.RemoveDictData(ctx, cmd)
}
